<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/element.css" rel="stylesheet"/>
    <link href="../css/styleindex.css" rel="stylesheet"/>
    <link href="../css/swiper.min.css" rel="stylesheet"/>
    <style>

    </style>
</head>
<body style="background:#EFF0F4;">

  <div class="mui-content">
    <div id="vm" class="x-examok" v-cloak>
      <div class="x-header-g" id="header">
        <a class="x-header-arrow" @click="api.closeWin()"></a>
        <div class="x-header-t">运营管理-制定训练计划</div>
      </div>
      <div class="container">
  			<!-- <div class="x-train-tabs">
  				<div class="x-train-items" v-for="(item,index) in tabsdata" :key="item.id" @click="changetab(index)" :class="{active:curId==index}">{{item}}</div>
  			</div> -->
  			<div class="x-train-tabs swiper-container">
  				<div class="swiper-wrapper">
  					<div class="swiper-slide x-train-items" v-for="(item,index) in tabsdata" :key="item.id" @click="changetab(index,item.id)" :class="{active:curId==index}">{{item.title}}</div>
  				</div>
  			</div>
        <div class="x-train-tb">
          <template>
            <el-table :data="tabledata" @cell-click="gotrainpro">
              <el-table-column label="序号" width="50" type="index"></el-table-column>
              <el-table-column label="人员姓名" width="">
                <template slot-scope="scope">
                  {{scope.row.username}}
                </template>
              </el-table-column>
              <el-table-column label="现职位" width="">
                <template slot-scope="scope">
                  {{scope.row.level_title}}
                </template>
              </el-table-column>
            </el-table>
          </template>
        </div>
		  </div>

    </div>
  </div>

  <script type="text/javascript" src="../script/vue.js"></script>
  <script type="text/javascript" src="../script/element.js"></script>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/base.js"></script>
  <script type="text/javascript" src="../script/jquery-1.11.1.min.js"></script>
  <script type="text/javascript" src="../script/swiper.min.js"></script>
	<script>
apiready = function () {



    //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
          tabsdata:[],
          curId:0,
          tabledata:[],

        }
      },
      created:function() {
        var that=this;


      },
      mounted:function(){
        var that=this;
        that.gettrainadmin(0)
      },
      methods: {
        //列
        gotrainpro:function(val){
          // console.log(JSON.stringify(val));
          api.openWin({
              name: 'trainpro',
              url: './trainpro.html',
              pageParam: {
                  id: val.id
              }
          });
        },
        //切换选项卡 表格数据
        changetab:function(index,id){
          var that = this;

          that.curId = index;
          that.gettrainadmin(id)
      		// mySwiper.slideToLoop(index, 500, false);
        },
        //获取训练管理 通道列表
        gettrainadmin:function(id){
          let that=this;
          api.ajax({
            url:baseurl+'api/practice/personList',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                deptid:id
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              // console.log(JSON.stringify(ret));
              if(ret.status == 1){
                  for(var i=0;i<ret.data.depts.length;i++){
                    that.tabsdata.push({
                      'title':ret.data.depts[i].title,
                      'id':ret.data.depts[i].id,
                    })
                  }
                  that.tabledata = ret.data.list;
                  that.$nextTick(function(){
                    var mySwiper = new Swiper('.swiper-container',{
                      freeMode: true,
                      loop:false,//设置 active slide 居中后，会有左右留白现象，添加此会让未尾的导航补齐前后空白
                      slideToClickedSlide: true,//设置为true则点击slide会过渡到这个slide。
                      slidesPerView: 3,
                      centeredSlides: false,//设定为true时，active slide会居中，而不是默认状态下的居左。
                      spaceBetween: 10,//slide之间设置距离
                      slidesOffsetBefore: 0,//设定slide与左边框的预设偏移量
                      slidesOffsetAfter: 0,//设定slide与右边框的预设偏移量

                    });

                  });
              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
      }
    })
	}

	</script>
</body>
</html>
